# @File :visaOrder.py
import time
import unittest

from configparser import ConfigParser
from Pages.PlanePage import PlanePage
from Pages.visaPage import visaPage
from Pages.tripPage import tripPage
# from Pages.visaDetailPage import visaDetailPage
from Pages.OrderListPage import OrderListPage
from Public import Gl
from Public.Login import Login
from Pages.AdminPage import AdminPage
from Pages.adminVisaDetailPage import adminVisaDetailPage
from Public.BaseOperate import BaseOperate


class visaOrder(unittest.TestCase):
    def setUp(self):
        parse = ConfigParser()
        #win需使用配置文件绝对路径
        parse.read('E:\DTSL\DTSL\Public\configurations.ini')
        self.driver = Gl.BrowserEngine(self).open_browser(self)
        self.L = Login()
        self.urlOBT = parse.get('OBT','url')
        self.useridOBT = parse.get('OBT','userid')
        self.passwordOBT = parse.get('OBT','password')
        self.urlAdmin = parse.get('admin','url')
        self.useridAdmin = parse.get('admin','userid')
        self.passwordAdmin = parse.get('admin','password')


    def tearDown(self):
        self.driver.quit()


    def test_1visaOrder(self):
        PP = PlanePage()
        VP = visaPage()
        self.L.LoginOBT(self.urlOBT,  self.useridOBT, self.passwordOBT)
        time.sleep(2)
        PP.closeNotice()
        #   PP.click_Close()
        #首页切换至签证产品，选择国家、常住地、日期，并查询
        VP.click_visaIcon()
        VP.chooseCounrty()
        VP.chooseResidencePalce()
        VP.chooseDepartDate()
        PP.click_searchBtn(-1)
        time.sleep(2)
        #签证列表页，选择指定签证产品下单
        VP.toBookVisa_list()
        VP.toBookVisa_detail()
        VP.selectPassengers()
        VP.submitOrder()
        #获取签证订单号
        BO = BaseOperate()
        global visaOrderNo
        visaOrderNo = BO.getOrderNo()
        print(visaOrderNo)


    def test_0visaOrder(self):
        AP = AdminPage()
        self.L.LoginAdmin(self.urlAdmin, self.useridAdmin, self.passwordAdmin)
        AP.goToVisaOrder()
        AP.selectOrder("QZ240826000952198")
        visaDetailPage = adminVisaDetailPage()
        visaDetailPage.distributeOrder()
        time.sleep(5)
        visaDetailPage.closeOrder()
        time.sleep(5)



if __name__ == '__main__':
    unittest.main()

